package main

import (
	"sort"
	"strconv"
	"strings"
)

func concat(a, b int) int {
	bits := 10
	for bits <= b {
		bits *= 10
	}
	return a*bits + b
}

func largestNumber(nums []int) string {
	if len(nums) == 0 {
		return ""
	}
	sort.Slice(nums, func(i, j int) bool {
		return concat(nums[i], nums[j]) > concat(nums[j], nums[i])
	})
	if nums[0] == 0 {
		return "0"
	}
	sb := strings.Builder{}
	for _, v := range nums {
		sb.WriteString(strconv.Itoa(v))
	}
	return sb.String()
}

func main() {
	println(largestNumber([]int{3, 30, 34, 5, 9}))
}
